#!/usr/bin/env sh

sudo yabai --load-sa
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"

# global settings
yabai -m config mouse_follows_focus          off
yabai -m config focus_follows_mouse          off
yabai -m config window_placement             first_child
yabai -m config window_topmost               off
yabai -m config window_shadow                off
yabai -m config window_opacity               off
yabai -m config window_opacity_duration      0.0
yabai -m config active_window_opacity        1.0
yabai -m config normal_window_opacity        1.0
yabai -m config window_border                off
yabai -m config window_border_width          6
# yabai -m config active_window_border_color   0xff7aa2f7
# yabai -m config normal_window_border_color   0xff444b6a
# yabai -m config active_window_border_color   0xff81A1C1
# yabai -m config normal_window_border_color   0xff7A808C
yabai -m config insert_feedback_color        0xff61afef
yabai -m config split_ratio                  0.50
yabai -m config auto_balance                 off
yabai -m config mouse_modifier               fn
yabai -m config mouse_action1                move
yabai -m config mouse_action2                resize
yabai -m config mouse_drop_action            swap

yabai -m config layout                       bsp
yabai -m config top_padding                  12
yabai -m config bottom_padding               12
yabai -m config left_padding                 12
yabai -m config right_padding                12
yabai -m config window_gap                   12

#yabai -m space 1 --label 
#yabai -m space 2 --label 
#yabai -m space 3 --label Document
#yabai -m space 4 --label IV
#yabai -m space 5 --label V
#yabai -m space 6 --label VI
#yabai -m space 7 --label VII
#yabai -m space 8 --label VIII
#yabai -m space 9 --label IX
#yabai -m space 10 --label X

# yabai -m rule --add app="Google Chrome" space=1
# yabai -m rule --add app="Alacritty"     space=2
# ^^ these are annoying
yabai -m rule --add app="Safari"        space=2
yabai -m rule --add app="Obsidian"      space=3
yabai -m rule --add app="提醒事项"      space=3
yabai -m rule --add app="goneovim"      space=1
yabai -m rule --add app="VimR"          space=1
yabai -m rule --add app="VimR.app"      space=1
yabai -m rule --add app="zathura"       space=1
yabai -m rule --add app="Safari浏览器"  space=1
yabai -m rule --add app="Safari"        space=1



yabai -m config external_bar all:27:0
# yabai -m config external_bar all:0:0

# 临时性的App 也就是manage=off不受到yabai平铺式的限制，之前怎么弹出来就怎么弹出来
# 查询窗口名指令 yabai -m query --windows --space
otherApp='^(IINA|访达|Calendar|日历|Bob|System Preferences|系统偏好设置|1Password 7|Mail|微信|WeChatc|QQ|Android Studio|印象笔记|iTerm2|Cubox|Cubox 助手|uTools)$'
yabai -m rule --add app="${otherApp}" manage=off

echo "yabai configuration loaded.."
